function [ population ] = createLGPPopulation( metadata,popSize,maxIndividualLength )
%UNTITLED4 Summary of this function goes here
%   Detailed explanation goes here
population.individuals = cell(popSize,1);
population.initialSize = popSize;

for i = 1:popSize
    numberOfLines = unidrnd(maxIndividualLength);
    ind = createLGPIndividual(numberOfLines,metadata.maxFunctionArity);
    %must put at least one terminal at the first line
    %search functionset for functions with arity zero    
    
    %now populate which functions are to appear in the lines of code
    %function index is first column
    numberOfFunctions = length(metadata.functionArgsTypes);
    ind.expressionList(:,1) = unidrnd(numberOfFunctions,numberOfLines,1);
    
    %place a terminal at the first position
    terminals = find(  sum(metadata.functionArgsTypes) == 0 );
    %whichTerminal = metadat.functionArgsTypes(
    
    %populate function arguments - at each line you can only refer
    %to previous lines of code
    for i = 1:numberOfLines
        %look up function arg types in metadata
        lineOfCode = ind.expressionList(i,:);
        argTypes = metadata.functionArgsTypes(:,lineOfCode(1));
    end
    population.individuals{i} = ind;
    
end
end

